﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>奇偶数的判断</title>
    <script type="text/javascript" language="JavaScript">
        function chk(num){
            alert((num % 2 === 0) ? "偶数" :"奇数");
        }
    </script>
</head>
<body>
<input  type="text" name="txt" value="4" id="txt" />
<button onclick="chk(txt.value)">判断</button>
</body>
</html>